package javabasics.finaldemo;

public class FinalDemo {

    final String attribute = null;//Variable 'attribute' might not have been initialized

    private String s;
    public FinalDemo(String s){
        this.s = s;
    }

    public static void main(String[] args) {
        final String s = new String("55");
        System.out.println("final修饰的对象变量：" + s);

//        s = new String("");//Cannot assign a value to final variable 's' final声明的对象变量不可以再指向其他对象

        final Integer i = new Integer(00);
        final FinalDemo finalDemo = new FinalDemo("ss");
        System.out.println(finalDemo.s);
        finalDemo.s = "改变数值";
        System.out.println(finalDemo.s);

        String c = "hello" + 2;
        System.out.println(c);


    }

    final class Father{
        final void fatherFinal(){
            System.out.println("final修饰的方法");
        }

        //final修饰的方法可以被重写
        final void fatherFinal(String s){
            System.out.println("final修饰的方法");
        }
    }

    //Cannot inherit from final 'javabasics.finaldemo.FinalDemo.Father'
//    class Son extends Father{

        //'fatherFinal()' cannot override 'fatherFinal()' in 'javabasics.finaldemo.FinalDemo.Father'; overridden method is final
//        void fatherFinal(){
//            System.out.println("final修饰的方法");
//        }
//    }
}
